import 'package:flutter/material.dart';
import 'package:flutter_juwo/common/common_index.dart';

class ProfitView {
  static flowList(var data) {
    return Container(
      child: Expanded(
        child: ListView.builder(
            primary: true,
            itemCount: data.length,
            itemBuilder: (BuildContext context, int index) {
              return _flowItem(data[index]);
            }),
      ),
    );
  }

  //income 已返收益
  //willIncome 预估未到账收益
  static profit(var income, var willIncome) {
    return Container(
      color: Colors.white,
      height: ScrUtil.w(200),
      margin: UiUtils.edgeOnly(b: 30),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          _profitItem("已返收益", income),
          _profitItem("预估未到账收益", willIncome),
        ],
      ),
    );
  }

  static _profitItem(txt, income) {
    return Expanded(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Container(child: UiUtils.t("$txt", size: 24, color: Colours.cText1)),
          Container(
              margin: UiUtils.edgeOnly(t: 20),
              child: UiUtils.t("$income",
                  size: 48, font: Font.PingFangBlod, color: Colours.cText0))
        ],
      ),
    );
  }

  static _flowItem(item) {
    return Container(
      margin: UiUtils.edgeOnly(b: 15),
      padding: UiUtils.edgeOnly(l: 30, r: 30),
      color: Colors.white,
      height: ScrUtil.w(168),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Container(
                  child: UiUtils.t(item["time"],
                      size: 24, color: Color.fromARGB(255, 179, 179, 179)),
                ),
                Container(
                  child: UiUtils.t(item["type"],
                      size: 24, color: Color.fromARGB(255, 255, 173, 16)),
                )
              ],
            ),
          ),
          Container(
            margin: UiUtils.edgeOnly(t: 40),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Container(
                  child: UiUtils.t(item["account"],
                      size: 24, color: Colours.cText0),
                ),
                Container(
                  child: UiUtils.t("${item["phone"]} ${item["msg"]}",
                      size: 24, color: Colours.cText0),
                ),
                Container(
                  child: UiUtils.t("+${item["money"]}",
                      size: 30, color: Color.fromARGB(255, 255, 102, 102)),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
